/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.pod.hoteishilton.gui;

import edu.pod.hoteishilton.facade.IFacade;
import edu.pod.hoteishilton.model.*;
import java.awt.event.KeyEvent;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

/**
 *
 * @author Tigaz
 */
public class ClientMain extends javax.swing.JFrame {

    /**
     * Creates new form Main
     */
    public ClientMain() {
        initComponents();

        try {
            facade = (IFacade) Naming.lookup("//localhost:12346/HoteisHiltonServer");

        } catch (NotBoundException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        } catch (MalformedURLException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }

        initDadosComponents();
        initDialogs();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        menuHoteisjPopupMenu = new javax.swing.JPopupMenu();
        gerenciasQuartosjMenuItem = new javax.swing.JMenuItem();
        removerHoteljMenuItem = new javax.swing.JMenuItem();
        reservajDialog = new javax.swing.JDialog();
        jPanel11 = new javax.swing.JPanel();
        jLabel16 = new javax.swing.JLabel();
        efetuarReservajButton = new javax.swing.JButton();
        dataEntradajXDatePicker = new org.jdesktop.swingx.JXDatePicker();
        dataSaidajXDatePicker = new org.jdesktop.swingx.JXDatePicker();
        jLabel23 = new javax.swing.JLabel();
        hoteisjComboBox = new javax.swing.JComboBox();
        jLabel14 = new javax.swing.JLabel();
        checkInjDialog = new javax.swing.JDialog();
        jPanel17 = new javax.swing.JPanel();
        fazerCheckInjButton1 = new javax.swing.JButton();
        quartosDisponiveisjComboBox = new javax.swing.JComboBox();
        jLabel18 = new javax.swing.JLabel();
        checkOutjDialog = new javax.swing.JDialog();
        jPanel18 = new javax.swing.JPanel();
        fazerCheckInjButton2 = new javax.swing.JButton();
        valorContajLabel = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        trocoContajLabel = new javax.swing.JLabel();
        valorPagojTextField = new javax.swing.JTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel3 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        nomeHospedeTextField = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        addHospedeButton = new javax.swing.JButton();
        telHospedeTextField = new javax.swing.JTextField();
        endHospedeTextField = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        emailHospedeTextField = new javax.swing.JTextField();
        cpfHospedeTextField = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        fazerReservaPagamentojButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        hospedesTable = new javax.swing.JTable();
        filtroHospedesjTextField = new javax.swing.JTextField();
        filtrarHospedesjButton = new javax.swing.JButton();
        limparHospedesjButton = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        reservasTable = new javax.swing.JTable();
        filtroReservasjTextField = new javax.swing.JTextField();
        filtrarReservasjButton = new javax.swing.JButton();
        limparReservasjButton = new javax.swing.JButton();
        hoteisjComboBox1 = new javax.swing.JComboBox();
        jLabel32 = new javax.swing.JLabel();
        fazerCheckInjButton = new javax.swing.JButton();
        cancelarReservajButton = new javax.swing.JButton();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        hospedagensTable = new javax.swing.JTable();
        filtroHospedagensjTextField = new javax.swing.JTextField();
        filtrarHospedagensjButton = new javax.swing.JButton();
        limparHospedagensjButton = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        hoteisHospjComboBox1 = new javax.swing.JComboBox();
        fazerCheckoutjButton = new javax.swing.JButton();

        menuHoteisjPopupMenu.setComponentPopupMenu(menuHoteisjPopupMenu);

        gerenciasQuartosjMenuItem.setText("Gerenciar Quarto(s)");
        gerenciasQuartosjMenuItem.setComponentPopupMenu(menuHoteisjPopupMenu);
        gerenciasQuartosjMenuItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                gerenciasQuartosjMenuItemActionPerformed(evt);
            }
        });
        menuHoteisjPopupMenu.add(gerenciasQuartosjMenuItem);

        removerHoteljMenuItem.setText("Remover Hotel");
        removerHoteljMenuItem.setComponentPopupMenu(menuHoteisjPopupMenu);
        menuHoteisjPopupMenu.add(removerHoteljMenuItem);

        reservajDialog.setTitle("Quartos");

        jPanel11.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Datas da Reserva"));

        jLabel16.setText("Data de entrada");

        efetuarReservajButton.setText("Fazer Reserva");
        efetuarReservajButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                efetuarReservajButtonActionPerformed(evt);
            }
        });

        jLabel23.setText("Data de saida");

        jLabel14.setText("Hotel");

        javax.swing.GroupLayout jPanel11Layout = new javax.swing.GroupLayout(jPanel11);
        jPanel11.setLayout(jPanel11Layout);
        jPanel11Layout.setHorizontalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel16)
                            .addComponent(jLabel23)
                            .addComponent(jLabel14))
                        .addGap(23, 23, 23)
                        .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(dataSaidajXDatePicker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(dataEntradajXDatePicker, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(hoteisjComboBox, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel11Layout.createSequentialGroup()
                        .addGap(76, 76, 76)
                        .addComponent(efetuarReservajButton)))
                .addContainerGap(44, Short.MAX_VALUE))
        );
        jPanel11Layout.setVerticalGroup(
            jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel11Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16)
                    .addComponent(dataEntradajXDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel23)
                    .addComponent(dataSaidajXDatePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel11Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(hoteisjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel14))
                .addGap(41, 41, 41)
                .addComponent(efetuarReservajButton)
                .addContainerGap(47, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout reservajDialogLayout = new javax.swing.GroupLayout(reservajDialog.getContentPane());
        reservajDialog.getContentPane().setLayout(reservajDialogLayout);
        reservajDialogLayout.setHorizontalGroup(
            reservajDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(reservajDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        reservajDialogLayout.setVerticalGroup(
            reservajDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(reservajDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        checkInjDialog.setTitle("Quartos");

        jPanel17.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Check-In"));

        fazerCheckInjButton1.setText("Fazer Check-In");
        fazerCheckInjButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fazerCheckInjButton1ActionPerformed(evt);
            }
        });

        jLabel18.setText("Quartos Disponiveis");

        javax.swing.GroupLayout jPanel17Layout = new javax.swing.GroupLayout(jPanel17);
        jPanel17.setLayout(jPanel17Layout);
        jPanel17Layout.setHorizontalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
                        .addComponent(quartosDisponiveisjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel17Layout.createSequentialGroup()
                        .addGap(76, 76, 76)
                        .addComponent(fazerCheckInjButton1)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel17Layout.setVerticalGroup(
            jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel17Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel17Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(quartosDisponiveisjComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(fazerCheckInjButton1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout checkInjDialogLayout = new javax.swing.GroupLayout(checkInjDialog.getContentPane());
        checkInjDialog.getContentPane().setLayout(checkInjDialogLayout);
        checkInjDialogLayout.setHorizontalGroup(
            checkInjDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(checkInjDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        checkInjDialogLayout.setVerticalGroup(
            checkInjDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(checkInjDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel17, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        checkOutjDialog.setTitle("Quartos");

        jPanel18.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Check-Out"));

        fazerCheckInjButton2.setText("Fazer Check-Out");
        fazerCheckInjButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fazerCheckInjButton2ActionPerformed(evt);
            }
        });

        valorContajLabel.setText("Valor da Conta R$");

        jLabel8.setText("Valor Pago R$");

        trocoContajLabel.setText("Troco R$");

        valorPagojTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                valorPagoJtextFieldKeyTyped(evt);
            }
        });

        javax.swing.GroupLayout jPanel18Layout = new javax.swing.GroupLayout(jPanel18);
        jPanel18.setLayout(jPanel18Layout);
        jPanel18Layout.setHorizontalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addComponent(trocoContajLabel)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel18Layout.createSequentialGroup()
                        .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(valorContajLabel)
                            .addGroup(jPanel18Layout.createSequentialGroup()
                                .addComponent(jLabel8)
                                .addGap(18, 18, 18)
                                .addComponent(valorPagojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 62, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addContainerGap(37, Short.MAX_VALUE))))
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGap(44, 44, 44)
                .addComponent(fazerCheckInjButton2)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel18Layout.setVerticalGroup(
            jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel18Layout.createSequentialGroup()
                .addGap(23, 23, 23)
                .addComponent(valorContajLabel)
                .addGap(18, 18, 18)
                .addGroup(jPanel18Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(valorPagojTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(trocoContajLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fazerCheckInjButton2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout checkOutjDialogLayout = new javax.swing.GroupLayout(checkOutjDialog.getContentPane());
        checkOutjDialog.getContentPane().setLayout(checkOutjDialogLayout);
        checkOutjDialogLayout.setHorizontalGroup(
            checkOutjDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(checkOutjDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        checkOutjDialogLayout.setVerticalGroup(
            checkOutjDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(checkOutjDialogLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel18, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Hoteis Hilton");
        setResizable(false);
        setType(java.awt.Window.Type.POPUP);

        jSplitPane1.setDividerLocation(350);

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Dados Ultima Hospedagem"));

        jLabel5.setText("Data de entrada:");

        jLabel9.setText("Data de saida:");

        jLabel10.setText("Hotel:");

        jLabel11.setText("Quarto:");

        jLabel12.setText("Valor:");

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel10)
                    .addComponent(jLabel9)
                    .addComponent(jLabel11)
                    .addComponent(jLabel12))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGap(40, 40, 40)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel11)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel12)
                .addContainerGap(194, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel4.setText("Email");

        nomeHospedeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                nomeHospedeJtextFieldKeyReleased(evt);
            }
        });

        jLabel2.setText("Endereço");

        addHospedeButton.setText("Cadastrar");
        addHospedeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addHospedeButtonActionPerformed(evt);
            }
        });

        telHospedeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                telHospedeJtextFieldKeyReleased(evt);
            }
        });

        endHospedeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                endHospedeJtextFieldKeyReleased(evt);
            }
        });

        jLabel3.setText("Telefone");

        jLabel1.setText("Nome");

        emailHospedeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                emailHospedeJtextFieldKeyReleased(evt);
            }
        });

        cpfHospedeTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                pesquisarHospedeFocusLost(evt);
            }
        });
        cpfHospedeTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                cpfHospedeJtextFieldKeyReleased(evt);
            }
        });

        jLabel22.setText("Cpf*");

        fazerReservaPagamentojButton.setText("Fazer Reserva");
        fazerReservaPagamentojButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fazerReservaPagamentojButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(100, 100, 100)
                        .addComponent(addHospedeButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(fazerReservaPagamentojButton))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addGap(43, 43, 43)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2)
                            .addComponent(jLabel3)
                            .addComponent(jLabel4)
                            .addComponent(jLabel22))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(emailHospedeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                            .addComponent(telHospedeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                            .addComponent(endHospedeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                            .addComponent(nomeHospedeTextField, javax.swing.GroupLayout.DEFAULT_SIZE, 150, Short.MAX_VALUE)
                            .addComponent(cpfHospedeTextField))))
                .addContainerGap(35, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                .addContainerGap(15, Short.MAX_VALUE)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cpfHospedeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(nomeHospedeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(endHospedeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(telHospedeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(emailHospedeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(addHospedeButton)
                    .addComponent(fazerReservaPagamentojButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jSplitPane1.setLeftComponent(jPanel3);

        hospedesTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Nome", "Cpf", "Endereço", "Telefone", "Email"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        hospedesTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                hospedesTableClicked(evt);
            }
        });
        jScrollPane1.setViewportView(hospedesTable);

        filtroHospedesjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                filtroHospedesButtonPressed(evt);
            }
        });

        filtrarHospedesjButton.setText("Pesquisar");
        filtrarHospedesjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filtrarHospedesjButtonActionPerformed(evt);
            }
        });

        limparHospedesjButton.setText("Limpar");
        limparHospedesjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limparHospedesjButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 505, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGap(0, 189, Short.MAX_VALUE)
                        .addComponent(filtroHospedesjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(filtrarHospedesjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limparHospedesjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(13, 13, 13))))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(filtroHospedesjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(filtrarHospedesjButton)
                    .addComponent(limparHospedesjButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
                .addContainerGap())
        );

        jSplitPane1.setRightComponent(jPanel4);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jSplitPane1)
        );

        jTabbedPane1.addTab("Hospedes", jPanel1);

        reservasTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null},
                {null, null, null, null, null}
            },
            new String [] {
                "Número", "Hospede", "CPF", "Data de entrada", "Data de saida"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        reservasTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                reservasTableClicked(evt);
            }
        });
        jScrollPane2.setViewportView(reservasTable);

        filtroReservasjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                filtroReservasjTextFieldfiltroHospedesButtonPressed(evt);
            }
        });

        filtrarReservasjButton.setText("Pesquisar");
        filtrarReservasjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filtrarReservasjButtonActionPerformed(evt);
            }
        });

        limparReservasjButton.setText("Limpar");
        limparReservasjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limparReservasjButtonActionPerformed(evt);
            }
        });

        hoteisjComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hoteisjComboBox1ActionPerformed(evt);
            }
        });

        jLabel32.setText("Hotel");

        fazerCheckInjButton.setText("Fazer Check-In");
        fazerCheckInjButton.setEnabled(false);
        fazerCheckInjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fazerCheckInjButtonActionPerformed(evt);
            }
        });

        cancelarReservajButton.setText("Cancelar Reserva");
        cancelarReservajButton.setEnabled(false);
        cancelarReservajButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelarReservajButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel32)
                        .addGap(18, 18, 18)
                        .addComponent(hoteisjComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(57, 57, 57)
                        .addComponent(fazerCheckInjButton)
                        .addGap(18, 18, 18)
                        .addComponent(cancelarReservajButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 91, Short.MAX_VALUE)
                        .addComponent(filtroReservasjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(filtrarReservasjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limparReservasjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane2))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(filtroReservasjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(filtrarReservasjButton)
                    .addComponent(limparReservasjButton)
                    .addComponent(hoteisjComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel32)
                    .addComponent(fazerCheckInjButton)
                    .addComponent(cancelarReservajButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
                .addGap(12, 12, 12))
        );

        jTabbedPane1.addTab("Reservas", jPanel2);

        hospedagensTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Hotel", "Num. Quarto", "Id. Reserva", "Nome do Hospede", "Data do Checkin", "Data do Checkout", "Valor da Hospedagem"
            }
        ) {
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false, false, false
            };

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        hospedagensTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                hospedagensTableClicked(evt);
            }
        });
        jScrollPane3.setViewportView(hospedagensTable);

        filtroHospedagensjTextField.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                filtroHospedagensjTextFieldfiltroHospedesButtonPressed(evt);
            }
        });

        filtrarHospedagensjButton.setText("Pesquisar");
        filtrarHospedagensjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filtrarHospedagensjButtonActionPerformed(evt);
            }
        });

        limparHospedagensjButton.setText("Limpar");
        limparHospedagensjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                limparHospedagensjButtonActionPerformed(evt);
            }
        });

        jLabel6.setText("Hotel");

        hoteisHospjComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                hoteisHospjComboBox1ActionPerformed(evt);
            }
        });

        fazerCheckoutjButton.setText("Fazer Checkout");
        fazerCheckoutjButton.setEnabled(false);
        fazerCheckoutjButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                fazerCheckoutjButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(18, 18, 18)
                        .addComponent(hoteisHospjComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(65, 65, 65)
                        .addComponent(fazerCheckoutjButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 216, Short.MAX_VALUE)
                        .addComponent(filtroHospedagensjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 115, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(filtrarHospedagensjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(limparHospedagensjButton, javax.swing.GroupLayout.PREFERRED_SIZE, 93, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPane3))
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGap(12, 12, 12)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(filtroHospedagensjTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(filtrarHospedagensjButton)
                    .addComponent(limparHospedagensjButton)
                    .addComponent(jLabel6)
                    .addComponent(hoteisHospjComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fazerCheckoutjButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 542, Short.MAX_VALUE)
                .addGap(12, 12, 12))
        );

        jTabbedPane1.addTab("Hospedagem", jPanel12);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 886, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 628, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void filtrarHospedesjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtrarHospedesjButtonActionPerformed

        sorterHospedesTable.setRowFilter(RowFilter.regexFilter(filtroHospedesjTextField.getText()));
    }//GEN-LAST:event_filtrarHospedesjButtonActionPerformed

    private void addHospedeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addHospedeButtonActionPerformed
        try {
            if (nomeHospedeTextField.getText().trim().equals("")) {
                JOptionPane.showMessageDialog(null, "Campo nome Obrigatorio!", "Hospede", JOptionPane.WARNING_MESSAGE);
            } else {
                Hospede h = new Hospede(nomeHospedeTextField.getText(), cpfHospedeTextField.getText(), endHospedeTextField.getText(), telHospedeTextField.getText(), emailHospedeTextField.getText());
                facade.addHospede(h);
                hospedes.put(h.getCpf(), h);
                fillTableHospedes(hospedesTable, hospedes);
                JOptionPane.showMessageDialog(null, "Usuario Adicionado/Editado com Sucesso!", "Hospede", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_addHospedeButtonActionPerformed

    private void limparHospedesjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limparHospedesjButtonActionPerformed
        addHospedeButton.setText("Cadastrar");

        cpfHospedeTextField.setText(null);
        nomeHospedeTextField.setText(null);
        endHospedeTextField.setText(null);
        telHospedeTextField.setText(null);
        emailHospedeTextField.setText(null);
        filtroHospedesjTextField.setText(null);

        sorterHospedesTable.setRowFilter(RowFilter.regexFilter(""));
        cpfHospedeTextField.setEditable(true);

        hospede = null;
    }//GEN-LAST:event_limparHospedesjButtonActionPerformed

    private void hospedesTableClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hospedesTableClicked
        if (evt.getClickCount() == 2) {
            hospede = (Hospede) hospedes.get(hospedesTable.getValueAt(hospedesTable.getSelectedRow(), 1));

            preencherHospede(hospede);
        }
    }//GEN-LAST:event_hospedesTableClicked

    private void filtroHospedesButtonPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_filtroHospedesButtonPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            filtrarHospedesjButton.doClick();
        }
    }//GEN-LAST:event_filtroHospedesButtonPressed

    private void gerenciasQuartosjMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_gerenciasQuartosjMenuItemActionPerformed
        reservajDialog.pack();
        reservajDialog.setVisible(true);
    }//GEN-LAST:event_gerenciasQuartosjMenuItemActionPerformed

    private void reservasTableClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_reservasTableClicked
        if (evt.getClickCount() == 2) {
            reserva = (Reserva) reservas.get(Integer.parseInt(reservasTable.getValueAt(reservasTable.getSelectedRow(), 0).toString()));
            if (reserva.getHospedagem() == null) {
                fazerCheckInjButton.setText("Check-In Reserva " + reserva.getId());
                cancelarReservajButton.setText("Cancelar Reserva " + reserva.getId());
                fazerCheckInjButton.setEnabled(true);
                cancelarReservajButton.setEnabled(true);
            } else {
                fazerCheckInjButton.setEnabled(false);
                cancelarReservajButton.setEnabled(false);
            }
        }
    }//GEN-LAST:event_reservasTableClicked

    private void filtroReservasjTextFieldfiltroHospedesButtonPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_filtroReservasjTextFieldfiltroHospedesButtonPressed
        // TODO add your handling code here:
    }//GEN-LAST:event_filtroReservasjTextFieldfiltroHospedesButtonPressed

    private void filtrarReservasjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtrarReservasjButtonActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_filtrarReservasjButtonActionPerformed

    private void limparReservasjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limparReservasjButtonActionPerformed
        fazerCheckInjButton.setEnabled(false);
        cancelarReservajButton.setEnabled(false);
        reserva = null;
    }//GEN-LAST:event_limparReservasjButtonActionPerformed

    private void pesquisarHospedeFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_pesquisarHospedeFocusLost
        if (hospedes.containsKey(cpfHospedeTextField.getText())) {
            hospede = (Hospede) hospedes.get(cpfHospedeTextField.getText());

            preencherHospede(hospede);
        }
    }//GEN-LAST:event_pesquisarHospedeFocusLost

    private void fazerReservaPagamentojButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fazerReservaPagamentojButtonActionPerformed
        if (hospede == null) {
            JOptionPane.showMessageDialog(null, "Favor selecionar o hospede na tabela!", "Reserva", JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (hospede.getSituacao()) {
            reservajDialog.setVisible(true);
        } else {
        }
    }//GEN-LAST:event_fazerReservaPagamentojButtonActionPerformed

    private void efetuarReservajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_efetuarReservajButtonActionPerformed
        Date dataDeEntrada, dataDeSaida;

        dataDeEntrada = dataEntradajXDatePicker.getDate();
        dataDeSaida = dataSaidajXDatePicker.getDate();
        Calendar dataAtual = Calendar.getInstance();
        dataAtual.add(Calendar.DAY_OF_MONTH, -1);

        if (dataDeEntrada == null || dataDeSaida == null) {
            JOptionPane.showMessageDialog(null, "Favor preencher todas as datas!", "Reserva", JOptionPane.WARNING_MESSAGE);
            return;
        }

        dataDeEntrada.setHours(12);
        dataDeSaida.setHours(12);

        if (dataDeEntrada.before(dataAtual.getTime())) {
            JOptionPane.showMessageDialog(null, "Data de entrada invalida!", "Reserva", JOptionPane.WARNING_MESSAGE);
            return;
        }
        if (dataDeSaida.before(dataDeEntrada) || dataDeSaida.equals(dataDeEntrada)) {
            JOptionPane.showMessageDialog(null, "Data de saida invalida!", "Reserva", JOptionPane.WARNING_MESSAGE);
            return;
        }

        try {
            hotel = facade.getHotel(hoteisjComboBox.getSelectedItem().toString());
            if (hotel.isReservaExistente(dataDeEntrada, dataDeSaida, hospede)) {
            }

            switch (hotel.isReservaPossivel(dataDeEntrada, dataDeSaida, hospede)) {
                case 1:
                    JOptionPane.showMessageDialog(null, "Hospede ja possui reserva entre os dias selecionados!", "Reserva", JOptionPane.WARNING_MESSAGE);
                    break;

                case 2:
                    JOptionPane.showMessageDialog(null, "Nao ha quartos disponiveis para as datas selecionadas!", "Reserva", JOptionPane.WARNING_MESSAGE);
                    break;

                case 3:
                    Reserva r = new Reserva();

                    r.setDataEntrada(dataDeEntrada);
                    r.setDataSaida(dataDeSaida);
                    r.setHospede(hospede);
                    hotel.addReserva(r);

                    reservas = hotel.getReservas();
                    facade.addHotel(hotel);
                    fillTableReservas(reservasTable, reservas);
                    JOptionPane.showMessageDialog(null, "Reserva realizada com sucesso!", "Reserva", JOptionPane.INFORMATION_MESSAGE);
                    break;
            }

        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_efetuarReservajButtonActionPerformed

    private void hospedagensTableClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_hospedagensTableClicked
        if (evt.getClickCount() == 2) {
            reserva = (Reserva) reservas.get(Integer.parseInt(hospedagensTable.getValueAt(hospedagensTable.getSelectedRow(), 1).toString()));
            System.out.println(hospedagensTable.getValueAt(hospedagensTable.getSelectedRow(), 1).toString());
            if (reserva.getHospedagem() != null) {
                fazerCheckoutjButton.setText("Check-out Reserva " + reserva.getId());
                fazerCheckoutjButton.setEnabled(true);
            } else {
                fazerCheckoutjButton.setEnabled(false);
            }
        }
    }//GEN-LAST:event_hospedagensTableClicked

    private void filtroHospedagensjTextFieldfiltroHospedesButtonPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_filtroHospedagensjTextFieldfiltroHospedesButtonPressed
        // TODO add your handling code here:
        sorterHospedesTable.setRowFilter(RowFilter.regexFilter(filtroHospedesjTextField.getText()));
    }//GEN-LAST:event_filtroHospedagensjTextFieldfiltroHospedesButtonPressed

    private void filtrarHospedagensjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtrarHospedagensjButtonActionPerformed
    }//GEN-LAST:event_filtrarHospedagensjButtonActionPerformed

    private void limparHospedagensjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_limparHospedagensjButtonActionPerformed
        fazerCheckoutjButton.setText("Fazer Check-Out");
        fazerCheckoutjButton.setEnabled(false);
    }//GEN-LAST:event_limparHospedagensjButtonActionPerformed

    private void hoteisjComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hoteisjComboBox1ActionPerformed
        try {
            reservas = facade.getReservas(hoteisjComboBox1.getSelectedItem().toString());
        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (reservas != null) {
            fillTableReservas(reservasTable, reservas);
        }
    }//GEN-LAST:event_hoteisjComboBox1ActionPerformed

    private void fazerCheckInjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fazerCheckInjButtonActionPerformed
        if (reserva == null) {
            JOptionPane.showMessageDialog(null, "Favor selecionar a reserva na tabela!", "Check-In", JOptionPane.WARNING_MESSAGE);
            return;
        }
        try {
            hotel = facade.getHotel(reserva.getHotel().getApelido());
            quartosVazios = hotel.getQuartosVazios();
        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }
        fillQuartosDisponiveisJcomboBox(quartosDisponiveisjComboBox, quartosVazios);
        checkInjDialog.setVisible(true);
    }//GEN-LAST:event_fazerCheckInjButtonActionPerformed

    private void fazerCheckInjButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fazerCheckInjButton1ActionPerformed
        Hospedagem hospedagem = new Hospedagem(reserva, reserva.getHotel());
        reserva.setHospedagem(hospedagem);
        hospedagem.setDataInicioHospedagem(Calendar.getInstance());
        hospedagem.setHospede(reserva.getHospede());
        for (Quarto q : quartosVazios) {
            if (q.getNumeroQuarto() == quartosDisponiveisjComboBox.getSelectedItem()) {
                hospedagem.setQuarto(q);

                break;
            }
        }
        try {
//            hotel = facade.getHotel(reserva.getHotel().getApelido());
            hotel.addReserva(reserva);

            facade.addHotel(hotel);
            fazerCheckInjButton.setEnabled(false);
            cancelarReservajButton.setEnabled(false);
            checkInjDialog.setVisible(false);
            JOptionPane.showMessageDialog(null, "Check-in do hospede " + reserva.getHospede().getNome() + " realizado com sucesso no quarto " + hospedagem.getQuarto().getNumeroQuarto() + "!", "Check-In", JOptionPane.INFORMATION_MESSAGE);
            fillTableHospedagens(hospedagensTable, hotel.getQuartosOcupados());

        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_fazerCheckInjButton1ActionPerformed

    private void cpfHospedeJtextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_cpfHospedeJtextFieldKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            addHospedeButton.doClick();
        }
    }//GEN-LAST:event_cpfHospedeJtextFieldKeyReleased

    private void nomeHospedeJtextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_nomeHospedeJtextFieldKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            addHospedeButton.doClick();
        }
    }//GEN-LAST:event_nomeHospedeJtextFieldKeyReleased

    private void endHospedeJtextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_endHospedeJtextFieldKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            addHospedeButton.doClick();
        }
    }//GEN-LAST:event_endHospedeJtextFieldKeyReleased

    private void telHospedeJtextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_telHospedeJtextFieldKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            addHospedeButton.doClick();
        }
    }//GEN-LAST:event_telHospedeJtextFieldKeyReleased

    private void emailHospedeJtextFieldKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_emailHospedeJtextFieldKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            addHospedeButton.doClick();
        }
    }//GEN-LAST:event_emailHospedeJtextFieldKeyReleased

    private void hoteisHospjComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_hoteisHospjComboBox1ActionPerformed
        ArrayList<Quarto> quartosOcupados = null;
        try {
            hotel = facade.getHotel(hoteisHospjComboBox1.getSelectedItem().toString());
            quartosOcupados = hotel.getQuartosOcupados();
            reservas = hotel.getReservas();

        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }
        if (quartosOcupados != null) {
            fillTableHospedagens(hospedagensTable, quartosOcupados);
        }
    }//GEN-LAST:event_hoteisHospjComboBox1ActionPerformed

    private void fazerCheckoutjButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fazerCheckoutjButtonActionPerformed
        hospedagem = reserva.getHospedagem();
        hospedagem.setDataFimHospedagem(Calendar.getInstance());
        hospedagem.calcularConta();
        valorContajLabel.setText("Valor da Conta R$" + hospedagem.getConta().getValor());

        hotel.addReserva(reserva);

        checkOutjDialog.setVisible(true);
    }//GEN-LAST:event_fazerCheckoutjButtonActionPerformed

    private void cancelarReservajButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelarReservajButtonActionPerformed
        if (reserva.getHospedagem() == null) {
            try {
                hotel = facade.getHotel(reserva.getHotel().getApelido());
                hotel.delReserva(reserva);
                reservas = hotel.getReservas();
                facade.addHotel(hotel);

                fillTableReservas(reservasTable, reservas);
                JOptionPane.showMessageDialog(null, "Reserva cancelada com sucesso!", "Reserva", JOptionPane.INFORMATION_MESSAGE);

            } catch (RemoteException ex) {
                Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
            }

        } else {
            JOptionPane.showMessageDialog(null, "Esta reserva ja esta ativa, favor fazer check-out", "Reserva", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_cancelarReservajButtonActionPerformed

    private void fazerCheckInjButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fazerCheckInjButton2ActionPerformed
        double valorPago = Double.parseDouble(valorPagojTextField.getText());
        if (valorPago >= hospedagem.getConta().getValor()) {
            hospedagem.getConta().setValorPago();


        } else {
            hospedagem.getConta().setValorPago(valorPago);
        }


        try {
            hotel.getQuarto(hospedagem.getQuarto().getNumeroQuarto()).setHospedagem(null);
            hospedagem.getQuarto().setHospedagem(null);
            hotel.addReserva(reserva);

            facade.addHotel(hotel);
            hospede = facade.getHospede(reserva.getHospede().getCpf());
            hospede.setUltimaHospedagem(hospedagem);
            facade.addHospede(hospede);
            fazerCheckoutjButton.setText("Fazer Check-Out");
            fazerCheckoutjButton.setEnabled(false);
            JOptionPane.showMessageDialog(null, "Check-Out realizado com sucesso!", "Check-Out", JOptionPane.INFORMATION_MESSAGE);
            checkOutjDialog.setVisible(false);
            fillTableHospedagens(hospedagensTable, hotel.getQuartosOcupados());

        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }

    }//GEN-LAST:event_fazerCheckInjButton2ActionPerformed

    private void valorPagoJtextFieldKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_valorPagoJtextFieldKeyTyped
        if (valorPagojTextField.getText().length() > 1) {
            double valorPago = Double.parseDouble(valorPagojTextField.getText().toString());
            trocoContajLabel.setText("Troco R$" + (valorPago - hospedagem.getConta().getValor()));
        }
    }//GEN-LAST:event_valorPagoJtextFieldKeyTyped

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(ClientMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(ClientMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(ClientMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(ClientMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new ClientMain().setVisible(true);


            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addHospedeButton;
    private javax.swing.JButton cancelarReservajButton;
    private javax.swing.JDialog checkInjDialog;
    private javax.swing.JDialog checkOutjDialog;
    private javax.swing.JTextField cpfHospedeTextField;
    private org.jdesktop.swingx.JXDatePicker dataEntradajXDatePicker;
    private org.jdesktop.swingx.JXDatePicker dataSaidajXDatePicker;
    private javax.swing.JButton efetuarReservajButton;
    private javax.swing.JTextField emailHospedeTextField;
    private javax.swing.JTextField endHospedeTextField;
    private javax.swing.JButton fazerCheckInjButton;
    private javax.swing.JButton fazerCheckInjButton1;
    private javax.swing.JButton fazerCheckInjButton2;
    private javax.swing.JButton fazerCheckoutjButton;
    private javax.swing.JButton fazerReservaPagamentojButton;
    private javax.swing.JButton filtrarHospedagensjButton;
    private javax.swing.JButton filtrarHospedesjButton;
    private javax.swing.JButton filtrarReservasjButton;
    private javax.swing.JTextField filtroHospedagensjTextField;
    private javax.swing.JTextField filtroHospedesjTextField;
    private javax.swing.JTextField filtroReservasjTextField;
    private javax.swing.JMenuItem gerenciasQuartosjMenuItem;
    private javax.swing.JTable hospedagensTable;
    private javax.swing.JTable hospedesTable;
    private javax.swing.JComboBox hoteisHospjComboBox1;
    private javax.swing.JComboBox hoteisjComboBox;
    private javax.swing.JComboBox hoteisjComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel32;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel11;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel17;
    private javax.swing.JPanel jPanel18;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JButton limparHospedagensjButton;
    private javax.swing.JButton limparHospedesjButton;
    private javax.swing.JButton limparReservasjButton;
    private javax.swing.JPopupMenu menuHoteisjPopupMenu;
    private javax.swing.JTextField nomeHospedeTextField;
    private javax.swing.JComboBox quartosDisponiveisjComboBox;
    private javax.swing.JMenuItem removerHoteljMenuItem;
    private javax.swing.JDialog reservajDialog;
    private javax.swing.JTable reservasTable;
    private javax.swing.JTextField telHospedeTextField;
    private javax.swing.JLabel trocoContajLabel;
    private javax.swing.JLabel valorContajLabel;
    private javax.swing.JTextField valorPagojTextField;
    // End of variables declaration//GEN-END:variables
    private static IFacade facade;
    private HashMap hospedes;
    private HashMap hoteis;
    private HashMap hospedagens;
    private Hospede hospede;
    private Hotel hotel;
    private Reserva reserva;
    private HashMap reservas;
    private Hospedagem hospedagem;
    private ArrayList<Quarto> quartosVazios;
    private TableRowSorter<TableModel> sorterHospedesTable;
    private TableRowSorter<TableModel> sorterQuartosTable;
    SimpleDateFormat formatador = new SimpleDateFormat("dd/MM/yyyy");

    private void initDadosComponents() {
        try {
            hospedes = facade.getHospedes();
            hoteis = facade.getHoteis();

            sorterHospedesTable = new TableRowSorter<>(hospedesTable.getModel());
            hospedesTable.setRowSorter(sorterHospedesTable);
            fillTableHospedes(hospedesTable, hospedes);

        } catch (RemoteException ex) {
            Logger.getLogger(ClientMain.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void fillTableHospedes(JTable hospedesTable, HashMap hospedes) {
        DefaultTableModel tm = (DefaultTableModel) hospedesTable.getModel();
        String[] row = new String[5];

        tm.setRowCount(0);
        for (Iterator it = hospedes.values().iterator(); it.hasNext();) {
            Object h = it.next();
            row[0] = ((Hospede) h).getNome();
            row[1] = ((Hospede) h).getCpf();
            row[2] = ((Hospede) h).getEndereco();
            row[3] = ((Hospede) h).getTelefone();
            row[4] = ((Hospede) h).getEmail();
            tm.addRow(row);
        }
        hospedesTable.setModel(tm);
    }

    private void preencherHospede(Hospede hospede) {
        cpfHospedeTextField.setText(hospede.getCpf());
        nomeHospedeTextField.setText(hospede.getNome());
        endHospedeTextField.setText(hospede.getEndereco());
        telHospedeTextField.setText(hospede.getTelefone());
        emailHospedeTextField.setText(hospede.getEmail());

        cpfHospedeTextField.setEditable(false);
        addHospedeButton.setText("Editar");

        if (hospede.getSituacao()) {
            fazerReservaPagamentojButton.setText("Fazer Reserva");
        } else {
            fazerReservaPagamentojButton.setText("Pagar Divida");
        }

    }

    private void initDialogs() {

        for (Iterator it = hoteis.values().iterator(); it.hasNext();) {
            Object o = it.next();
            hoteisHospjComboBox1.addItem(((Hotel) o).getApelido());
            hoteisjComboBox.addItem(((Hotel) o).getApelido());
            hoteisjComboBox1.addItem(((Hotel) o).getApelido());
        }

        reservajDialog.pack();
        checkInjDialog.pack();
        checkOutjDialog.pack();

    }

    private void fillTableReservas(JTable reservasTable, HashMap reservas) {
        DefaultTableModel tm = (DefaultTableModel) reservasTable.getModel();
        String[] row = new String[5];

        tm.setRowCount(0);

        for (Iterator it = reservas.values().iterator(); it.hasNext();) {
            Reserva r = (Reserva) it.next();
            row[0] = Integer.toString(r.getId());
            row[1] = r.getHospede().getNome();
            row[2] = r.getHospede().getCpf();
            row[3] = formatador.format(r.getDataEntrada().getTime());
            row[4] = formatador.format(r.getDataSaida().getTime());
            tm.addRow(row);
        }

        reservasTable.setModel(tm);
    }

    private void fillTableHospedagens(JTable hospedagensTable, ArrayList<Quarto> quartos) {
        DefaultTableModel tm = (DefaultTableModel) hospedagensTable.getModel();
        String[] row = new String[7];

        tm.setRowCount(0);
        if (quartos == null || quartos.size() == 0) {
            return;
        }
        for (Quarto quarto : quartos) {
            if (quarto.isOcupado()) {
                row[0] = quarto.getHotel().getApelido();
                row[1] = Integer.toString(quarto.getNumeroQuarto());
                row[2] = Integer.toString(quarto.getHospedagem().getReserva().getId());
                row[3] = quarto.getHospedagem().getHospede().getNome();
                row[4] = formatador.format(quarto.getHospedagem().getDataInicioHospedagem().getTime());
                if (quarto.getHospedagem().getDataFimHospedagem() == null) {
                    row[5] = "Checkout nao realizado";
                    row[6] = "Checkout não realizado";
                } else {
                    row[5] = formatador.format(quarto.getHospedagem().getDataFimHospedagem().getTime());
                    row[6] = Double.toString((quarto.getPreco() * quarto.getHospedagem().getDiasHospedagem()));
                }

                tm.addRow(row);
            }
        }

        hospedagensTable.setModel(tm);
    }

    private void fillQuartosDisponiveisJcomboBox(JComboBox quartosDisponiveisjComboBox, ArrayList<Quarto> quartosVazios) {

        quartosDisponiveisjComboBox.removeAllItems();
        for (Quarto q : quartosVazios) {
            quartosDisponiveisjComboBox.addItem(q.getNumeroQuarto());
        }
    }
}
